/**
 * @Description:
 * @Author 卞鹏飞 <228443632@qq.com>
 * @create 12/08/24 2:57 PM
 */
import useAppStore from '@store/use-app-store'
import useLayoutStore from '@store/use-layout-store'

// import type { UnwrapRef } from 'vue'

// import type {} from '@root/types/app-store'

type TBeforeCloseRouteValueV2 = (options?: { done?: Function; tabKey?: string }) => Promise<boolean>

/**
 * 是否允许关闭路由
 * @param cb
 */
export function onBeforeCloseRouteV2(cb: TBeforeCloseRouteValueV2) {
  const { router } = useAppStore()
  const layoutStore = useLayoutStore()
  const fullPath = router.currentRoute.fullPath
  layoutStore.beforeCloseRouteV2[fullPath] = cb
}
